<template>
  <div class="app">
    <h2 :style="{fontSize: postFontSize + 'em'}">app{{childInput}}</h2>
    <button @click="handleChild" v-if="childRef && childRef.aaa">{{childRef.aaa}}</button>

    <Child :title="title" :title2="title2" ref="childRef"  @enlarge-text="postFontSize += 0.1"/>
    <Child2 v-bind="postProps" />
    <Child3 v-model:childInput="childInput" />
  </div>
</template>

<script setup>
import { ref } from 'vue';
import Child from "./components/Child"; // 静态引入组件
import Child2 from "./components/Child2"; // 静态引入组件
import Child3 from "./components/Child3"; // 静态引入组件

const title = ref('22233')
const title2 = ref('title2')
const childRef = ref()
const postFontSize = ref(1)
const childInput = ref('default')

const postProps = {
  id: '2333',
  name: '名字'
}
const handleChild = () => {
  childRef.value.hello('获取子组件的信息')
  console.log(childRef.value.aaa)
}

</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.app{
  background: grey;
  padding: 10px;
}
</style>
